import request from '@/utils/request'

const pre = '/fmea'

// 下载项目导入模板
export function downLoadTemplate(query) {
  return request({
    url: `${pre}/common/importProject/downloadImportFmeaTemplate`,
    method: 'get',
    params: query
  })
}

// 查询项目数量
export function selectTtProjectCount(query) {
  return request({
    url: `${pre}/common/project/selectTtProjectCount`,
    method: 'get',
    params: query
  })
}

// 查询项目列表
export function listProject(query) {
  return request({
    url: `${pre}/common/project/list`,
    method: 'get',
    params: query
  })
}

// 查询项目详细
export function getProject(id) {
  return request({
    url: `${pre}/common/project/${id}`,
    method: 'get'
  })
}

// 新增项目
export function addProject(data) {
  return request({
    url: `${pre}/common/project`,
    method: 'post',
    data: data,
    timeout: 100000
  })
}

// 修改项目
export function updateProject(data) {
  return request({
    url: `${pre}/common/project`,
    method: 'put',
    data: data
  })
}

// 修改项目状态
export function insertTtProjectState(data) {
  return request({
    url: `${pre}/common/project/updateTtProjectState`,
    method: 'put',
    data: data
  })
}

// 删除项目
export function delProject(id) {
  return request({
    url: `${pre}/common/project/` + id,
    method: 'delete'
  })
}

// 导出项目
export function exportProject(query) {
  return request({
    url: '/common/project/export',
    method: 'get',
    params: query
  })
}

// 获取团队成员
export function getTeamList(query) {
  return request({
    url: `${pre}/common/project/getTtTeamGroupUserList`,
    method: 'get',
    params: query
  })
}

// 获取项目团队成员（按key分组）
export function getGroupUserList(query) {
  return request({
    url: `${pre}/common/project/getGroupUserList`,
    method: 'get',
    params: query
  })
}

// 获取产品关系
export function getProjProdList(id) {
  return request({
    url: `${pre}/common/project/getTrProjectProductList/${id}`,
    method: 'get'
  })
}

// 获取产品小类
export function getProjProdClassList(id) {
  return request({
    url: `${pre}/common/project/getTrProjectProductClassList/${id}`,
    method: 'get'
  })
}

// 获取客户关系
export function getProjCusList(id) {
  return request({
    url: `${pre}/common/project/getTrProjectCustomerList/${id}`,
    method: 'get'
  })
}

// 获取工厂关系
export function getProjFactoryList(id) {
  return request({
    url: `${pre}/common/project/getTrProjectFactoryList/${id}`,
    method: 'get'
  })
}

// 获取物料供应商关系
export function getMaterialSupplyList(id) {
  return request({
    url: `${pre}/common/project/getTrMaterialSupplierList/${id}`,
    method: 'get'
  })
}

// 获取物料小类
export function getProjMaterialClass(id) {
  return request({
    url: `${pre}/common/project/getTrProjectMaterialClassList/${id}`,
    method: 'get'
  })
}

// 获取设备
export function getProjEquipment(id) {
  return request({
    url: `${pre}/common/project/getTrProjectEquipmentList/${id}`,
    method: 'get'
  })
}

// 根据项目id获取严重度规则
export function getTmRuleSeverityByPid(id) {
  return request({
    url: `${pre}/common/project/getTmRuleSeverityByPid/${id}`,
    method: 'get'
  })
}

// 根据项目id获取发生度规则
export function getTmRuleOccurrenceByPid(id) {
  return request({
    url: `${pre}/common/project/getTmRuleOccurrenceByPid/${id}`,
    method: 'get'
  })
}

// 根据项目id获取探测度规则
export function getTmRuleDetectionByPid(id) {
  return request({
    url: `${pre}/common/project/getTmRuleDetectionByPid/${id}`,
    method: 'get'
  })
}

export function exportFmeaGridFile(data) {
  return request({
    url: `/fmea/common/project/exportFmeaGridFile`,
    method: 'get',
    params: data
  })
}

export function exportFmeaPdfFile(data) {
  return request({
    url: `/fmea/common/project/exportFmeaPdfFile`,
    method: 'get',
    params: data
  })
}

export function copyProjectByProjectId(projectId) {
  return request({
    url: `${pre}/common/project/createCopyFmeaProject/${projectId}`,
    method: 'get'
  })
}

// 升版
export function projectUpgrade(query) {
  return request({
    url: `/fmea/common/project/upgrade`,
    method: 'get',
    params: query
  })
}

// 查询项目列表
export function listProjectExact(query) {
  return request({
    url: `${pre}/common/project/exactQuery`,
    method: 'get',
    params: query
  })
}

// 计算AP
export function getAp(query) {
  return request({
    url: `${pre}/common/project/getAp`,
    method: 'get',
    params: query
  })
}

// 下载模板
export function getImportProjectData(data) {
  return request({
    url: `${pre}/common/importProject/getImportProjectData`,
    method: 'post',
    data: data
  })
}

// 下载项目导入模板
export function downLoadFlowChartTemplate(query) {
  return request({
    url: `${pre}/common/importProject/downloadFlowChartTemplate`,
    method: 'get',
    params: query
  })
}

// 查询项目列表
export function listExportBasicProject(query) {
  return request({
    url: `${pre}/common/project/selectBasicProjectList`,
    method: 'get',
    params: query
  })
}

// 下载Bom导入模板
export function downLoadBomImportTemplate(query) {
  return request({
    url: `${pre}/common/importProject/downloadImportBomTemplate`,
    method: 'get',
    params: query
  })
}

// 下载FlowChart导入模板
export function downLoadFlowChartImportTemplate(query) {
  return request({
    url: `${pre}/common/importProject/downloadFlowChartTemplate`,
    method: 'get',
    params: query
  })
}

// 下载特性清单导入模板
export function downLoadFeatureImportTemplate(query) {
  return request({
    url: `${pre}/common/importProject/downloadCharacterListTemplate`,
    method: 'get',
    params: query
  })
}
